// Mixins

// 文本省略
@mixin text-ellipsis($lines: 1) {
  @if $lines == 1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  } @else {
    display: -webkit-box;
    -webkit-line-clamp: $lines;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

// Flex布局
@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

@mixin flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

// 响应式
@mixin mobile {
  @media (max-width: 768px) {
    @content;
  }
}

@mixin tablet {
  @media (min-width: 769px) and (max-width: 1024px) {
    @content;
  }
}

@mixin desktop {
  @media (min-width: 1025px) {
    @content;
  }
}

@mixin large-desktop {
  @media (min-width: #{$breakpoint-lg}) {
    @content;
  }
}

@mixin xl-desktop {
  @media (min-width: #{$breakpoint-xl}) {
    @content;
  }
}

@mixin xxl-desktop {
  @media (min-width: #{$breakpoint-xxl}) {
    @content;
  }
}

@mixin desktop-2k {
  @media (min-width: #{$breakpoint-2k}) {
    @content;
  }
}

@mixin desktop-4k {
  @media (min-width: #{$breakpoint-4k}) {
    @content;
  }
}

@mixin desktop-5k {
  @media (min-width: #{$breakpoint-5k}) {
    @content;
  }
}

// 真正的等比缩放mixin
@mixin true-scale($scale: 1) {
  transform: scale($scale);
  transform-origin: center top;
  
  // 调整缩放后的容器尺寸
  @if $scale > 1 {
    // 缩放后需要调整容器宽度，避免内容溢出
    width: calc(100% / #{$scale});
    margin-left: auto;
    margin-right: auto;
    
    // 调整最小高度
    min-height: calc(100vh / #{$scale});
  }
}

// 等比缩放函数（保留用于特殊场景）
@function scale-value($value, $scale: 1) {
  @return $value * $scale;
}

// 容器宽度自适应 - 支持高分辨率屏幕（等比缩放）
@mixin container-width {
  width: 100%;
  // 常规分辨率不限制最大宽度，让页面占满屏幕
  padding: 0 $spacing-lg;

  @include large-desktop {
    max-width: $max-width-large;
    padding: 0 $spacing-xl;
  }

  @include xl-desktop {
    max-width: $max-width-xl;
    padding: 0 $spacing-xxl;
  }

  @include desktop-2k {
    max-width: $max-width-2k;
    padding: 0 scale-value($spacing-lg, $scale-2k);
  }

  @include desktop-4k {
    max-width: $max-width-4k;
    padding: 0 scale-value($spacing-lg, $scale-4k);
  }

  @include desktop-5k {
    max-width: $max-width-5k;
    padding: 0 scale-value($spacing-lg, $scale-5k);
  }

  @include mobile {
    padding: 0 $spacing-md;
  }
}

// Section 标题样式
@mixin section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: $spacing-md;

  h3 {
    font-size: $font-size-xl;
    margin: 0;
    display: flex;
    align-items: center;

    i {
      color: $text-primary;
      margin-right: $spacing-sm;
      font-size: $font-size-xxl;
    }

    span {
      font-weight: $font-weight-semibold;
      color: $text-color;
    }
  }

  a {
    color: $text-color-secondary;
    font-size: $font-size-sm;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: $transition-base;

    &:hover {
      color: $text-primary;
    }

    span {
      margin-right: 4px;
    }

    i {
      font-size: $font-size-base;
    }
  }
}

// 按钮样式
@mixin button($bg-color, $text-color: #fff) {
  background: $bg-color;
  color: $text-color;
  border: 1px solid $bg-color;
  border-radius: $border-radius-base;
  padding: 8px 16px;
  font-size: $font-size-base;
  font-weight: $font-weight-medium;
  cursor: pointer;
  transition: all $transition-base ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  &:hover {
    background: darken($bg-color, 10%);
    border-color: darken($bg-color, 10%);
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
}

